The function primescount
returns the number of primes found up to a given bound. The implemented algorithm uses the Miller-Rabin Primality Test to determine whether a number is prime or not. The number of iterations is configurable, to set the desired accuracy.
primescount(n, iter = 10, bar = TRUE)# S3 method for default
primescount(n, iter = 10, bar = TRUE)
# S3 method for numeric
primescount(n, iter = 10, bar = TRUE)
# S3 method for vli
primescount(n, iter = 10, bar = TRUE)
upper bound of the interval in which we want to count the number of primes; object of class vli or 32 bits integer
number of iterations for each number being tested; numeric
to choose if display or not a progress bar; boolean
Javier Leiva Cuadrado
if (FALSE) {
## Counting primes up to 200
primescount(n = 200, iter = 10, bar = TRUE)
## Computing the approximation of pi(x)
pi(200)
## Showing the numbers by using the Solovay-Strassen test
primes(n = 200, iter = 10, test = "SS", bar = TRUE)
}
Run the code above in your browser using DataLab